﻿define(['jquery'], function ($) {
    var categoryAjax = categoryAjax || {};

    categoryAjax.getCategories = function (callBack) {
        var serviceUrl = "http://localhost/WebConversion.Mvc/Service/DataService.svc/Category/All";
        getData(serviceUrl, function (result) {
            callBack(result || {});
        });
    };

    function getData(url, onSucess, onFailed, t) {
        $.ajax({
            type: "GET",
            contentType: "application/json",
            url: url,
            dataType: 'json',
            success: onSucess,
            error: onFailed != null ? 
                function (xh, msg, e) {
                     onFailed(xh, msg, e);
                 } : 
                function (xh, msg, e) {
                     console.log(xh + msg + e);
                },
            timeout: (!t ? 3600000 : t)
        });
    }

    return categoryAjax;
});